package webdemo.controller.index;

import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class Index {
	@RequestMapping("/index.do")
	public ModelAndView index(Model model, @RequestParam(required=false) String name) {
		model.addAttribute("shopTitle", "My shop title");
		model.addAttribute("shopName", "My shop name");
		model.addAttribute("shopDesc", "desc");
		
		String key = "key";
		String value = "value";
		Map<String, String> category = new LinkedHashMap<String, String>();
		for (int i = 0; i < 10; i++) {
			String count = "_" + (i + 1);
			category.put(key + count, value + count);
		}
		model.addAttribute("category", category);
		
		Map<String, String> topSearch = new LinkedHashMap<String, String>();
		for (int i = 0; i < 5; i++) {
			String count = "_" + (i + 1);
			topSearch.put(key + count, value + count);
		}
		model.addAttribute("topSearch", topSearch);
		return new ModelAndView("index/index");
	}
}
